
var cols = [[
    {type:'checkbox'}
    ,{field:'username',  title: '用户名',sort: true}
    ,{field:'name', title: '姓名', sort: true}
    ,{field:'mobile', title: '手机号码'}
    ,{field:'sex',  title: '性别',templet: function(d){
            return d.sex==0?'男':'女';
        }},
    {field:'status',  title: '状态',templet: function(d){
            return d.status==0?'禁用':'正常';
        }}
    ,{ align:'center',toolbar: '#barUtil', title:"操作"}
]]
layui.config({
    base: '/static/layui/'
}).extend({
    index: 'index'
}).use(['layer','table'], function () {
    var table = layui.table,$ = layui.$;
    var tableins = initTable(table, "userTable", "/sys/user/page", cols, true, 80);
    //监听工具条
    table.on('tool(userTable)', function(obj){
        var data = obj.data;
       if(obj.event === 'del'){
           delLayUiTable(null, null, data.id, "/sys/user/del", data.username);
        } else if(obj.event === 'edit'){
           openWindow('900px', '450px', '编辑角色', '/sys/user/formView?id=' + data.id);
        }
    });
    $("#del").on('click', function () {
        delLayUiTable(table, "userTable", null, "/user/role/del");
    });
    $('#search').on('click',function () {
        reloadTable(tableins, {username:$('#username').val()});
    })
});
